myApp.controller('JumpServerController',function($scope,$http){
    $scope.jumpServerList = [];
    $scope.count = 0;
    $http.post(java_url+'/beetle/jumpServer/getJumpServerList',{
        tokenId:getTokenId()
    }).success(function(data){
        if(data.code == '0'){
            $scope.count = data.data.count;
            if(data.data.count == 0){
                return;
            }else{
                $scope.jumpServerList = data.data.list;
                return;
            };
        }else if(data.code == '2'){
            window.location.href = "/beetle/App/module/login/tpl/login.html";
            return;
        }else{
            alert(data.desc);
            return;
        };
    });

    $scope.gotoAddS = function () {
        window.location.href = "#/menu/editJumpServer/1/";
    };

    $scope.delS = function (ip) {
        if(!confirm("确定删除该跳板机?")){
            return;
        };

        $http.post(java_url+'/beetle/jumpServer/editJumpServerInfo',{
            type:"3",
            ip:ip,
            tokenId:getTokenId()
        }).success(function(data){
            if(data.code == '0'){
                alert("删除成功");
                $scope.jumpServerList.splice(index,1);
            }else if(data.code == '2'){
                window.location.href = "/beetle/App/module/login/tpl/login.html";
                return;
            }else{
                alert(data.desc);
                return;
            };
        });
    };

    $scope.gotoUpdateS = function (ip) {
        window.location.href = "#/menu/editJumpServer/2/"+ip;
    };
});